<?php namespace nimo\providers;

use App;
use View;
use Event;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Support\ServiceProvider;
use nimo\facades\Profiler as Profiler;

class ProfilerServiceProvider extends ServiceProvider
{
	protected static $currenttime;

	public function register()
	{
		$this->app['profiler'] = $this->app->share(function($app)
		{
			return new \nimo\common\develop\Profiler(LARAVEL_START);
		});
		$this->app->booting(function()
		{
			$loader = \Illuminate\Foundation\AliasLoader::getInstance();
			$loader->alias('Profiler', 'nimo\facades\Profiler');
		});
		$this->app->before(function(){
			Profiler::pass("app");
		});
		$this->app->after(function(){
			Profiler::pass("shutdown");
		});
		$this->app->shutdown(function(){
			echo Profiler::render();
		});
		Event::listen('composing:*', function() {
			Profiler::pass("view");
		});
	}

	/**
	 * Get the services provided by the provider.
	 *
	 * @return array
	 */
	public function provides()
	{
		return array();
	}
}
